<?php
define('NEED_PERMISSION','CSR_OR_PRODUCT');
include '_init_.php';
	$orderManager = Order_Manager::getOrderManager($_REQUEST['id']);
if($orderManager == null)
	exit("Not exist");
if($orderManager->getStatus() != Order_Manager::$STATUS_SAVED)
	exit("Not allowed");
$orderManager->init();
$act = isset($_REQUEST['act'])?$_REQUEST['act']:'';
$noteIndex = isset($_REQUEST['noteindex'])?$_REQUEST['noteindex']:'';
if($act == 'save')
{
	if(strlen(trim($noteIndex)) > 0)
	{
		$orderManager->updateNote($_REQUEST['note'],intval($noteIndex));
	}else{
		$orderManager->addNote($_REQUEST['note']);
	}
	$orderManager->persistOrderInfo();
	AppMain::refreshParentFrame();
}
$orderInfo = $orderManager->getInfo();
$noteContent = '';
if(strlen($noteIndex) > 0)
{
	$noteContent = $orderInfo['note_list'][$noteIndex]['content'];
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>備註</title>
<link href="css/main.css" rel="stylesheet" type="text/css" />
</head>

<body>
<form action="cosii.php">
<input type="hidden" name="act" value="save"/>
<input type="hidden" name="id" value="<?php echo $orderManager->getId();?>"/>
<input type="hidden" name="noteindex" value="<?php echo $noteIndex;?>"/>
<div class="mainf-8">
  <ul>
        <li class="maina-1f">
備註<img src="images/line3.gif" width="21" height="12" /></li>
         <li class="maina-1l">
           <textarea name="note" class="maine-keyino" ><?php echo Util::html_safe($noteContent);?></textarea>
        </li>
      
  </ul>
</div>
<div class="mainf-7">
<ul>
<li class="article-1g"><input name="" type="button" class="article-1a_btn" value="<?php if(strlen($noteIndex) > 0){echo "修改";}else{ echo "新增";}?>" onclick="document.forms[0].submit();return false;"/></li>
</ul>
</div>
</form>
</body>
</html>
